package com.lei2j.command;

public class RemoteControl {

	private Command[] onCommands;
	
	private Command[] offCommands;
	
	private Command undoCommand;

	public RemoteControl() {
		onCommands = new Command[7];
		offCommands = new Command[7];
		for (int i = 0; i < 7; i++) {
			onCommands[i] = new NoCommand();
			offCommands[i] = new NoCommand();
		}
		undoCommand = new NoCommand();
	}

	public void setCommand(int slot,Command onCommand,Command offCommand) {
		onCommands[slot] = onCommand;
		offCommands[slot] = offCommand;
	}
	
	public void onButtonWasPushed(int slot) {
		onCommands[slot].execute();
		undoCommand = onCommands[slot];
	}
	
	public void offButtonWasPushed(int slot) {
		offCommands[slot].execute();
		undoCommand = offCommands[slot];
	}

	public Command getUndoCommand() {
		return undoCommand;
	}

	public void setUndoCommand(Command undoCommand) {
		this.undoCommand = undoCommand;
	}
	
	public void undoButtonCommand() {
		undoCommand.undo();
	}
}
